// 定义汽车接口
interface Car {
    void assemble();
    void paint();
    void polish();
}

// Sedan（轿车）类实现汽车接口
class Sedan implements Car {
    @Override
    public void assemble() {
        System.out.println("Assembling Sedan...");
    }

    @Override
    public void paint() {
        System.out.println("Painting Sedan...");
    }

    @Override
    public void polish() {
        System.out.println("Polishing Sedan...");
    }
}

// SUV类实现汽车接口
class SUV implements Car {
    @Override
    public void assemble() {
        System.out.println("Assembling SUV...");
    }

    @Override
    public void paint() {
        System.out.println("Painting SUV...");
    }

    @Override
    public void polish() {
        System.out.println("Polishing SUV...");
    }
}

class CarFactory {
    // 根据类型创建汽车对象
    public static Car createCar(String type) {
        if (type.equalsIgnoreCase("sedan")) {
            return new Sedan();
        } else if (type.equalsIgnoreCase("suv")) {
            return new SUV();
        } else {
            throw new IllegalArgumentException("Invalid car type: " + type);
        }
    }
}

// 测试
public class Main {
    public static void main(String[] args) {
        // 创建轿车
        Car sedan = CarFactory.createCar("sedan");
        sedan.assemble();
        sedan.paint();
        sedan.polish();

        System.out.println();

        // 创建SUV
        Car suv = CarFactory.createCar("suv");
        suv.assemble();
        suv.paint();
        suv.polish();
    }
}
